name: Build

on:
  workflow_dispatch:
  pull_request:
    branches:
      - '*'
  push:
    branches:
      - 'master'
      - 'hotfix-*'

jobs:
  build:
    name: "Build"
    runs-on: ubuntu-latest
    strategy:
      matrix:
        java-version: [ '17.0.x' ]
    steps:
      - uses: actions/checkout@v2.3.4

      - name: Set up JDK ${{ matrix.java-version }}
        uses: actions/setup-java@v2
        with:
          distribution: 'zulu'
          java-version: ${{ matrix.java-version }}

      - name: Build with Gradle
        run: ./gradlew build -x test

      - name: Run tests
        if: always()
        run: ./gradlew --no-build-cache cleanTest test
